/**
 * Created by liubin on 2014/11/25.
 * 这是用户模块
 * 包含用户一览，用户追加，用户删除功能
 */
define([
    'angular',
    'angular-couch-potato',
    'angular-ui-router',

],function (ng, couchPotato) {

    "use strict";

    var module = ng.module('app.user', [
        'ui.router'
    ]);
    couchPotato.configureApp(module);
    module.config(function ($stateProvider, $couchPotatoProvider){
        $stateProvider.state('app.user', {
            abstract: true,
            url: '/user',
            data: {
                title: '用户'
            }
        }).state('app.user.list', {
            url: '',
            data: {
                title: '用户一览'
            },
            views: {
                "content@app": {
                    controller: 'UserListCtrl',
                    templateUrl: 'app/user/views/list.html',
                    resolve: {
                        deps: $couchPotatoProvider.resolveDependencies([
                            'user/controllers/UserListCtrl',
                            'user/models/User'
                        ])
                    }
                }
            }
        }).state('app.user.add', {
            url: '/add',
            data: {
                title: '用户新增'
            },
            views: {
                "content@app": {
                    controller: 'UserAddCtrl',
                    templateUrl: 'app/user/views/add.html',
                    resolve: {
                        deps: $couchPotatoProvider.resolveDependencies([
                            'user/controllers/UserAddCtrl',
                            'user/models/User'
                        ])
                    }
                }
            }
        }).state('app.user.view', {
            url: '/view/:id',
            data: {
                title: '用户编辑'
            },
            views: {
                "content@app": {
                    controller: 'UserEditCtrl',
                    templateUrl: 'app/user/views/view.html',
                    resolve: {
                        deps: $couchPotatoProvider.resolveDependencies([
                            'user/controllers/UserEditCtrl',
                            'user/models/User'
                        ])
                    }
                }
            }
        });
    });
    module.run(function ($couchPotato) {
        module.lazy = $couchPotato;
    });
    return module;
});